package mspbots.data.tl.prod.jira.listener;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import mspbots.data.tl.entity.ResultMessageModel;
import mspbots.data.tl.prod.jira.service.*;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Log4j2
@Service
@Component
@RequiredArgsConstructor
public class JiraSyncListenner {

    private final JiraSprintService jiraSprintService;
    private final JiraTeamService jiraTeamService;
    private final JiraUserService jiraUserService;
    private final JiraProjectService jiraProjectService;
    private final JiraIssueService jiraIssueService;
    private final JiraWorklogService jiraWorklogService;

    @RabbitListener(queues = "jira.sprint.tl")
    public void syncJiraSprint(ResultMessageModel model) {
        jiraSprintService.sync(model);
    }

    @RabbitListener(queues = "jira.team.tl")
    public void syncJiraTeam(ResultMessageModel model) {
        jiraTeamService.sync(model);
    }

    @RabbitListener(queues = "jira.user.tl")
    public void syncJiraUser(ResultMessageModel model) {
        jiraUserService.sync(model);
    }

    @RabbitListener(queues = "jira.project.tl")
    public void syncJiraProject(ResultMessageModel model) {
        jiraProjectService.sync(model);
    }

    @RabbitListener(queues = "jira.issue.tl")
    public void syncJiraIssue(ResultMessageModel model) {
        jiraIssueService.sync(model);
    }

    @RabbitListener(queues = "jira.worklog.tl")
    public void syncJiraWorklog(ResultMessageModel model) {
        jiraWorklogService.sync(model);
    }

}
